package com.lightsaber.trade.as.entity.reta;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.lightsaber.trade.core.common.util.Calc;
import com.lightsaber.trade.core.entity.BaseEntity;
import com.lightsaber.trade.core.entity.account.Organization;

/**
 * Alarm.
 */
@Entity
@Table(name = "reta_order")
public class Order extends BaseEntity {

    @Column(name = "customer_name", length = 20)
    private String customerName;

    @Column(name = "name", length = 20)
    private String name;

    @Column(name = "description", length = 100)
    private String description;

    @Column(name = "total_price")
    private Double totalPrice;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "order_template_id")
    private OrderTemplate orderTemplate;

    @OneToMany(mappedBy = "order", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<OrderItem> orderItemList;

    @ManyToOne
    @JoinColumn(name = "org_id")
    private Organization organization;

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public OrderTemplate getOrderTemplate() {
        return orderTemplate;
    }

    public void setOrderTemplate(OrderTemplate orderTemplate) {
        this.orderTemplate = orderTemplate;
    }

    public Double getTotalPrice() {
        return totalPrice;
    }

    public String getTotalPriceStr() {
        return Calc.leaveTwoDigital(totalPrice);
    }

    public void setTotalPrice(Double totalPrice) {
        this.totalPrice = totalPrice;
    }

    public List<OrderItem> getOrderItemList() {
        return orderItemList;
    }

    public void setOrderItemList(List<OrderItem> orderItemList) {
        this.orderItemList = orderItemList;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Organization getOrganization() {
        return organization;
    }

    public void setOrganization(Organization organization) {
        this.organization = organization;
    }

}
